\section{Language Reference Manual}

\subsection{Lexical conventions}

There are 5 kinds of tokens: identifiers, keywords, constants,
operators, and separators. Tokens are separated by whitespace or new
line characters.

\subsubsection{Comments}
	
Comment blocks begin and end with the colon character (:).\footnote{It
  is DiGr tradition (but not syntactically required) to follow a
  starting comment character or lead a closing comment character with
  a left or right parenthesis to form a smiley or frowny face.}

\subsubsection{Identifiers}

An identifier is a sequence of letters, numbers and underscores, that
begin with a letter. Upper and lower case letters are considered
distinct. Identifiers are at least one character long, but no maximum
length. Identifiers cannot start with any reserved DiGr keywords.

\subsubsection{Keywords}
	
The following keywords are reserved for use by the language.

\begin{Verbatim}
  add
  addby
  addfront
  addbyfront
  call
  current
  crawl
  edge
  flt
  from
  in
  int
  node
  opt
  out
  print
  queue
  rule
  set
  str
  while
  with
\end{Verbatim}

\subsubsection{Constants}

Constants types in DiGr are either {\tt int}s, {\tt flt}s, or {\tt
  str}s. They will be discussed later.

\subsubsection{Operators}

The list of operators in DiGr, grouped into orders of precedence from
highest to lowest, is below. Note that not all operators act on all
DiGr types.

\begin{Verbatim}
        * / %
        + - 
        -> <- --
        == !=
        <= < >= >
        |
        && ||
        =
\end{Verbatim} 

Some of these are binary operators, and some have a more specialized
use. Their application will be discussed in the relevant section
below.

\subsubsection{Separators}

Semicolons (;) separate arguments in opt definitions. The comma
character (,) is used to separate argument in an opt call, node
children in a connection context, and initial values in an array
declaration. Curly brackets are used to separate blocks of code.

\subsubsection{Scoping and Execution}

DiGr has a global scope in which {\tt crawls}, {\tt opts} and {\tt
  rules} (only) may be declared. Every DiGr program must contain an
{\tt opt} named {\tt main} which takes no arguments, which is where
code execution begins.

DiGr is statically and locally scoped within each crawl, rule or opt,
but an important exception is that modifying outgoing variables
modifies the corresponding variable in the scope the crawl or opt was
called from.

\subsubsection{Statements}

DiGr is an imperative language. All statements are terminated with the
! symbol.\footnote{In DiGr, when you write a statement, you must
  really mean it!} Statements can be grouped into blocks using open
curly brace \{ and closed curly brace \}.

\subsubsection{The print() opt}

{\tt print()} is a built in DiGr opt that prints its argument, which
can be any {\tt int}, {\tt str}, or {\tt flt} separated by a comma
(,). It is the basic mechanism by which DiGr passes information from a
running program.

\subsection{Primitive Types}

There are five kinds of primitive types: {\tt int}, {\tt flt}, {\tt
  str}, {\tt node}, {\tt edge}, and several derived types, including
{\tt rule} and {\tt crawl}. All primitive types must be declared
before they can be assigned or dereferenced. Primitive types are
declared with their type name and the name of the bound identifier:

\begin{Verbatim}
        type identifiername!
\end{Verbatim}

All primitive types are assigned by being on the left side of the {\tt
  =} operator. A primitive type can be assigned as it is declared:

\begin{Verbatim}
        type identifiername = initial_value!
\end{Verbatim}

\subsubsection{Basic Primitive Types}

The {\tt int} (integer) is a signed, base 10 whole number. The range
of {\tt int}s is machine-specific.

Example:

\begin{Verbatim}
        int magNum = 42!
\end{Verbatim}

{\tt Flt}s (floats) are a representation of real, decimal numbers.

\begin{Verbatim}
	flt pi = 3.14!
	int pi = 3.14! :( error ):
\end{Verbatim}

{\tt Str}s (strings) begin and end with a double quote ("). The double
quote itself (") and the backslash ($\backslash$) must both be escaped
with a backslash. (e.g. $\backslash\backslash$ and
$\backslash${\tt"}). Strings are compared lexicographically.

Example:

\begin{Verbatim}
	str myName = "Ari"!
	str myNumber = 10! :( won't work, 10 is not a str, it is an int ):
	str myNumber = "10"! :) this will work (:
\end{Verbatim}

%"

The common mathematical operators {\tt + - * /} have the usual meaning
when used between two {\tt int}s, two {\tt flt}s, or an {\tt int} and
a {\tt flt}. \% is defined only between two {\tt int}s. In the case of
an {\tt int} and a {\tt flt}, the result will match the argument with
the least precision.

Example:

\begin{Verbatim}
	int numA = 42!
	flt numA1 = 42!
        flt numB = 10.5!
	flt result = numA + numB!         : result will be 52, not 52.5. :
        : This would also be true if result was of type int. :
	flt result1 = numA1 + numB!     : result1 will be 52.5 :
\end{Verbatim}
	
The addition operator can be used on two strings, and results in
concatenation. If the result is not stored anywhere, the concatenation
has no effect on the original strings.

Example:

\begin{Verbatim}
	str first = "Ari"!
	str last = "Golub"!
	str fullname = first + " " + last!
	print(fullName)!                  : prints "Ari Golub" :
\end{Verbatim}

\subsubsection{Node}

The {\tt node} is a primitive type in DiGr that represents a node in
directed and undirected graphs, and other abstract objects. {\tt
  Nodes} are connected to other {\tt nodes} through {\tt edges}. A
{\tt node} must be declared before it can be used, unless it is
created inside a connection context (see below). A {\tt node} can hold
as many {\em attributes} of any name as the user wishes. Attributes
are designed to be a flexible concept, and can be created and modified
on the fly with little overhead.

{\bf Node opts}

Each nodes has built in {\tt opts} (DiGr functions) that can be called
by placing a dot (.) after the name of the node followed by the {\tt
  opt} you wish to call. The functions are {\tt child}, {\tt parent},
{\tt inedge}, {\tt inedges}, {\tt outedge} and {\tt outedges}.

\begin{itemize}
\item {\tt (node) node.child(int n)} : Returns the (n+1)th child of
  the node counted by {\tt node.children()}. If n is not within the
  inclusive range {\tt (0,node.children()-1)}, this function throws a
  runtime exception.

\item {\tt (node) node.parent(int n)} : Returns the (n+1)th parent of
  the node counted by {\tt node.parents()}. If n is not within the
  inclusive range {\tt (0,node.parents()-1)}, this function throws a
  runtime exception.

\item {\tt (int) node.inedges} : Returns the integer number of edges
  coming in to the node.

\item {\tt (int) node.outedges} : Returns the integer number of
  edges coming out of the node.

\item {\tt (edge) node.inedge(int n)} : Returns the (n+1)th edge
  coming into the node. If n is not within the inclusive range {\tt
    (0,node.inedges()-1)}, this function throws a runtime error.

\item {\tt (edge) node.outedge(int n)} : Returns the (n+1)th edges
  going out of the node. If n is not within the inclusive range {\tt
    (0,node.outedges()-1)}, this function throws a runtime error.

\item {\tt (int) node.<attributeName>} : Returns the value of the
  attribute named\\ {\tt <attributeName>}. See below for more
  information.

\end{itemize}

Undirected edges qualify as both in and out edges for the purposes of
these functions. Thus, the children and parents of the current node
can be the same set of nodes.

Example (using connection context language, see below):

\begin{Verbatim}
        node tree[5] = | 0->1,(2->4) |!
        node head = tree[0]!
        print(head.inedges)!          : prints "0" :
        print(head.outedges)!         : prints "2" :
        edge myEdge = head.inedges(0)!  : myEdge is the edge from 0 -> 1 :
\end{Verbatim}

{\bf Node attributes}

Attributes are integer values stored under a variable name within the
node. Attributes are defined simply by attempting to assign a value to
them. In DiGr, referencing an undefined attribute automatically
creates an attribute of that name with a value of 0 in the node!

To get or set the value of an attribute, follow the {\tt node} name
with a dot (.) and the name of the attribute. Attributes are declared
by treating this as an identifier, and can be normally assigned with
(=). Node attribute names cannot start with the names of any built-in
node functions, including {\tt inedge}, {\tt outedge}, {\tt child} and
{\tt parent}.

Example:

\begin{Verbatim}
        node myNode!	
	myNode.weight = 32!
	int twoWeight = myNode.weight * 2!	: twoWeight = 64 :
\end{Verbatim}

%"

%As a special case, the compiler will allow you the user declare or set
%the attributes of an entire array of nodes as follows:

%\begin{Verbatim}	
%	node myNodes[5]!
%        float myNodes.cost!
%        myNodes.cost = 7!     
%        : all five nodes now have a "cost" attribute of 7
%\end{Verbatim}

Attributes that are declared but not initialized will have value of zero.

\begin{Verbatim}
	node myNode!
	int t = myNode.weight!
	print(t)!      : prints “0” :
\end{Verbatim}

{\bf Operations on Nodes}

The (=) operator between two nodes binds the identifier on the left
to the object dereferenced by the identifier on the right.

The ({\tt -$>$}) and ({\tt $<$-}) operators between two nodes will
create an unnamed directed edge from the first node to the second, or
the second to the first, respectively. Alternatively, the ({\tt --})
operator will create an unnamed undirected edge.

Example:

\begin{Verbatim}
	node tree[5] = | 0 -> 1, (2 -> 4) |!
	node head = tree[0]!
	head.weight = 10!
	node alt = tree[1]!
	alt.weight = 20!
	alt = head!	
	print(alt.weight)!    : prints 10 :
	node last = tree[4]!  : reference to node number 4 from first line :
	head <- last!         
        : creates a directed edge out of last and into head :
\end{Verbatim}

\subsubsection{Edge}

The {\tt edge} is the complementary type to a {\tt node} in DiGr. An
edge can be explicitly declared and named, but most often an {\tt
  edge} object is created anonymously as a result of linking nodes. An
edge not bound to an identifier can still be accessed via the {\tt
  inedge()}/{\tt outedge()} function of a {\tt node}. Like {\tt
  node}s, {\tt edge}s can be given any number of attributes.


Example:

\begin{Verbatim}
        node tree[5] = | 0->1,(2->4) |!
        node head = tree[0]!
        edge myEdge = head.outedges(0)!
\end{Verbatim}

Declaring a handle to an edge but not assigning to anything will
create two anonymous nodes for the directed edge to point between.

\begin{Verbatim}
        edge e!
        node nout = edge.innode! 
        : valid reference since this object exists :
\end{Verbatim}

{\bf Edge opts}

Each {\tt edge} has built in {\tt opt}s (DiGr functions) that can be
called by placing a dot (.) after the name of the node followed by the
{\tt opt} you wish to call. The functions are {\tt innode} and {\tt
  outnode}.

\begin{itemize}
\item {\tt (node) edge.innode} : Returns the node this edge is
  pointing to. 

\item {\tt (node) edge.outnode} : Returns the node this edge is
  leaving

\item {\tt (int) edge.<attributeName>} : Returns the value of the
  attribute named\\ {\tt <attributeName>}. See below for more
  information.

\end{itemize}

Undirected edges are implemented as two directed edges in both
configurations between the two nodes.

{\bf Edge attributes}

{\tt Edge}s have attributes in a manner almost identical to {\tt
  node}s. To get or set the value of an attribute, follow the {\tt
  edge} name with a dot (.) and the name of the attribute. Attributes
are declared by treating this as an identifier, and can be normally
assigned with (=). Edge attribute names cannot start with the names of
any built-in edge functions, including {\tt innode} and {\tt outnode}.

Example:

\begin{Verbatim}
        node tree[4] = | 0 -> 1, (2 -> 4) |!
        node head = tree[0]!
        edge myEdge = head.inedges(1)!	
        : myEdge points to edge between 0 and 2 :
        node three = myEdge.innode!	
        : three points to node 2 :
        myEdge.value = 17!
\end{Verbatim}
%"
{\bf Operations on Edges}

The (=) operator between two {\tt edge}s binds the identifier on the
left to the object dereferenced by the identifier on the left. 

Example:

\begin{Verbatim}
        node tree[5] = | 0 -> 1, (2 -> 4)|!
        node head = tree[0]!
        edge e1 = head.outedges(0)!     : e1 is between 0 and 1 :
        edge e2 = tree[2].outedges(0)!  : e2 is between 2 and 4 :
        e1 = e2!                        
        : the handle e1 now refers to the edge between 2 and 4 :
\end{Verbatim}


\subsection{Derived Types}

\subsubsection{Arrays}

DiGr supports arrays built out of any primitive type. Arrays are
allocated by giving a type and an identifier for the array, similar to
creating a single instance of that type, but following the identifier
with an open and closed bracket and the integer number of elements in
the array in between the brackets. 

\begin{Verbatim}
        type arrayidentifier[number_elements]!
\end{Verbatim}

{\bf Initialization}

Alternately, the user can initialize the entire array at declaration
by placing the initial value of sequential elements inside curly
brackets, separated by commas. Giving the array a different array
length than what the DiGr compiler infers from context will cause an
error.

Examples:

\begin{Verbatim}
	int arr1[3]!
	arr1[0] = 10!
	int arrDeclared[4] = {1, 2, 3, 4}!
	node tree[3] = | 0 -> (1 -> 2)|!
        node badIntTree[3] = {17, 41}!
	node badNodeTree[2] = |1 -> 2 -> 3|!	
        : wrong, too many nodes in connection context for array size :
\end{Verbatim}

{\bf Array operations}

Array indexing begins at 0, and elements are accessed by appending
square brackets with the element index to the end of the array. Trying
to index into an array outside the bounds of the array will generate a
run-time error.

The (=) operator can be used on individual elements of an array to
change the value of that element. It can {\em not} be used to set one
array equal to another.
	
\subsubsection{Opts}

%"

{\tt Opts} (operations) are the DiGr functions. {\tt opts} must
declare their input and output variables as part of their
signature. As a result, there are no return types in DiGr {\tt
  opts}. When called, "in" variables can be constants, but "out"
variables must be a previously declared identifier of the proper type.

{\tt Opt}s are declared with a sequence of arguments in a parenthesis
block separated by semicolons (;), and with the body of the {\tt opt}
inside curly brackets. Each argument is denoted {\tt in} or {\tt out},
its type and is given the local identifier to which the value is bound
when the {\tt opt} is called. The body of an {\tt opt} can contain any
standard DiGr code except further {\tt opt}/{\tt crawl}/{\tt rule}
definitions.

Example:

\begin{Verbatim}	
	opt myFunc(in int var1; in int var2; out int result) {
              if ( var1 > 10 ) {
	           result = var1 * 2!
              }	
              else {
	           result = var1 + var2!
	      }
        }

        int result!
        myFunc(3,12,result)!
        print(result)!	: prints 15 :
        myFunc(11,7,result)!
        print(result)!	: prints 22 :
\end{Verbatim}

\subsubsection{Crawl}

A {\tt crawl} is the DiGr type used to traverse a tree. {\tt Crawl}s
are similar to an {\tt opt} that will run its code on every node it
visits, when given which node to start at and the rules for moving to
additional nodes. They are general enough to be used for a variety of
purposes, but provide enough built-in functionality to quickly define
different traversal behaviors and operations.

When called, a {\tt crawl} creates an internal queue of the next nodes
to visit, and visits them one at a time by popping the next node off
the front of the queue. It executes its code at each node. Each {\tt
  crawl} also has a {\tt rule} that controls which nodes to add to the
queue at any given moment (usually somehow connected to the current
node, see the {\tt rule} section below). A {\tt crawl} only knows
about one {\tt rule} at a time, but this rule can be changed
dynamically. In this way, DiGr implements a level of abstraction in
tree traversal: {\tt crawl}s describe {\em what} one does at a {\tt
  node}, while {\tt rule}s describe {\em where} one goes next. When
run, a {\tt crawl} must be given an initial {\tt node} to start at and
an initial {\tt rule} for how to move on from there.

Variables passed to crawls persist between iterations of the crawl
code being executed on nodes, but variables declared in the crawl are
redeclared each time. Crawls may recursively call themselves.

{\tt Crawl}s are defined with an {\tt opt}-like set of in and out
variables:

\begin{Verbatim}
crawl myCrawl(in intype1 invar1; ... ; out outtype1 outvar1; ...) {
  : list of crawl statements
}
\end{Verbatim}

Crawls are executed as follows:

\begin{Verbatim}
myCrawl(myvar1; myvar2; ...; myoutvar1; ...) from mynode1 with myrule;
\end{Verbatim}

Where "mynode1" is a {\tt node} that serves as the initial starting
point of the tree traversal, and "myrule" is a {\tt rule} that assigns
the initial traversal {\tt rule} to this crawl (see below). {\tt from}
and {\tt with} are reserved keywords used primarily for readability.

In addition to standard DiGr code, the crawl body can contain the
following three operations:

\begin{itemize}

\item {\tt (node) current}: Reference to the current node the crawl is
  visiting. This is the handle the crawl uses to perform local
  computation on the node.

\item {\tt call}: Executes the current {\tt crawl}'s {\tt rule}. There
  is no return value.

\item {\tt set <newrule>}: Here, {\tt <newrule>} is a {\tt rule}. This
  updates the rule currently executed by the crawl upon a {\tt call}
  statement. There is no return value.

\end{itemize}

After executing all statements in the crawl body and reaching the
closing parenthesis, the crawl automatically moves on to the next node
in the queue and starts again. If there are no more nodes in the
queue, the crawl terminates with no return value. Any locally-scoped
in and out variables persist between crawl operations on different
nodes.

\subsubsection{Rule}

A {\tt rule} is a special form of {\tt opt} with no arguments that is
used by a {\tt crawl} to control and inform tree traversal. This
abstraction separates tree traversal from tree modification (which is
done in the body of a {\tt crawl}, see above) into two distinct sets
of operations. A {\tt rule} can be used in any number of {\tt crawl}s,
but a {\tt crawl} knows about only one {\tt rule} (but can update
which one it is using).

Given a current {\tt node}, a rule determines which {\tt nodes}, if
any, should be added to the internal double-ended queue. {\tt Rules}
can modify either end of the queue, but {\tt crawls} will always pop
the next node off the {\em front} to decide where to go next. A {\tt
  rule} is declared as follows:

\begin{Verbatim}
        rule myRule {
            : rule body goes here :
        }
\end{Verbatim}

There is one special keyword and four built-in opts that the {\tt
  rule} uses to manipulate the queue and guide an effective crawl:

\begin{itemize}	
\item {\tt (node) current}: A reference to the current node the crawl
  is at.

\item {\tt add(node)}: Takes a node as an argument and adds it to the
  {\em back} of the queue. This operation does not return a value.

\item {\tt addfront(node)}: Takes a node as an argument and adds it to
  the {\em front} of the queue. This operation does not return a
  value.

\item {\tt addby(<property>, <ordering>, number\_to\_add )}: Takes 3
  arguments: the property on which to sort, the ordering to use on
  that property, and how many of the winning nodes to add to the {\em
    back} of the queue. The syntax for the first two arguments is
  described below. If there are fewer children than the amount
  requested, {\tt addBy} will add as many as it can. Returns nothing.

\item {\tt addbyfront(<property>, <ordering>, number\_to\_add )}:
  Similar to {\tt addBy()}, but adds the winning nodes to the {\em
    front} of the queue.

\end{itemize}

The first argument to {\tt addby} and {\tt addbyfront} is the property
being evaluated to determine queuing order, written as {\tt
  edge.<attName>} or {\tt node.<attName>}, where {\tt <attName>} is
the name of the attribute to be used for selection, and the keyword
{\tt node} or {\tt edge} indicates whether the rule is to sort
children nodes by their attributes or by the attributes of the edges
connecting them to the current node.

The second argument describes how to order nodes or edges using the
selected attribute. The special symbols dollar sign (\$) and tilde
($\tilde{}$) tell the rule to sort in default ascending or descending
order, respectively. 

The third argument sets a maximum on the number of nodes to add to the
queue. The {\tt rule} will add up to, but not over, this number of
nodes to the queue.

Example:
\begin{Verbatim}
	rule depthFirst {
	    int n = 0!
	    while (n < current.outedges) {
                  add(current.child(n))!
                  n= n+1!
	    }
	}

	rule breadthFirst {
	    int n = 0!
	    while (n < current.outedges) {
                  addfront(current.child(n))!
                  n= n+1!
	    }
	}

	rule weightFirstThreeMax {,
	    addby(node.weight,$,3)!	
            : this will add at most three children to the back of the
            queue, starting with the node with the greatest weight  :
	}
\end{Verbatim}
%$

Note that the only handle to the tree being crawled is {\tt current},
the node that the crawl is at. This is a design choice to enforce the
abstraction that a {\tt rule} only does evaluation, and not
modification.

\subsection{Connection Context}

The connection context is the easiest way to create an entire tree of
nodes in a single line. The connection context has a special grammar
and is only valid inside pipe ({\tt |}) operators.  It {\em must} be
on the right-hand side of an assignment to a node array, which has the
same size as the number of nodes in the described tree.

\subsubsection{Grammar}

The grammar of the language used to describe a tree inside the
connection context can be formally defined as follows (with {\tt tree}
as the starting symbol):

\begin{Verbatim}
tree:             node edge children
edge:             -> | <- | --
children:         child, children | child
child:            node | ( tree )
node:             LIT_INT
\end{Verbatim}

{\tt LIT\_INT} is any integer. Integers are references to the node
array that prefixes the connection context, and are 0-indexed. The
{\tt ->} symbol is somewhat analogous to the standard DiGr operator
which is written the same way. It binds the node referenced on the
left to the tops of the subtrees listed on the right.

The multiple children of a node are separated by commas, and can be a
single node (e.g. {\tt |0->1|}) or a subgraph which is wrapped in
parenthesis (e.g. {\tt |0->(1->2)|}, in which case node 1 is connected
to node 2), or to multiple nodes (e.g. {\tt |0->1,2,3|}, in which case
node 0 is connected to nodes 1 2 and 3). The {\tt --} operator is
similar to {\tt ->} but creates undirected edges.

The size of the array must be large enough to include all of the nodes
listed. If a node isn't listed in the connection context, that element
of the array is a free-floating node unconnected to the rest of the
tree.

Examples:
\begin{Verbatim}
: create a two node graph with a directed edge between the two:
         node simple[2] = |0 -> 1|!
: create a three node graph with node 0 pointing to node 1 and
: node 1 pointing to node 2:
         node lineofthree[3] = |0 -> (1 -> 2)|!
: create a three node graph with node 0 pointing to nodes 1 and 2:
         node split[3] = |0 -> 1, 2|!
: create a directed four-cycle:
	 node fourcycle[4] = |0 -> (1 -> (2 -> (3 -> 4)))|!
: create a complete 4-graph:
        node fourcomplete[4] = |0--(1--2,3),(2--3),3|!
: create a 6-node bipartite graph (with odds and evens in the two
: partitions, respectively):
 	node bipartite[6] = |0--(1--(2--3,5)),(3--(4--5))|!
\end{Verbatim}

\subsection{Logic}

\subsubsection{Conditional Logic}

DiGr uses C-style "if then else" conditional logic statements. These
statements can take the following forms:

\begin{Verbatim}
  if (expression) { list_of_statements }
  if (expression) { list_of_statements } else { list_of_statements }
\end{Verbatim}

where "expression" has integer type (DiGr boolean expressions are
equivalent to {\tt ints}), and the statements are standard DiGr
statements.

\subsubsection{Boolean Logic}

DiGr has several boolean logic symbols: {\tt ||} (conditional or),
{\tt \&\&} (conditional and), {\tt ==} (conditional equality), {\tt
  !=} (conditional inequality), {\tt <} (less than), {\tt <=} (less
than or equal to), {\tt >} (greater than), and {\tt >=} (greater than
or equal to). These symbols can be used to create boolean statements
of arbitrary complexity for use in while loops or if statements.

%"

Example:
\begin{Verbatim}
	node myNode!
	myNode.weight = 19!
        myNode.id = 21!
	while(myNode.weight < 10 || myNode.id == 13) {
		myNode.weight = myNode.weight + 1!
		if((myNode.weight % 20) == 0) {
			myNode.id == myNode.id * 2!
                }
        }
        print(myNode.id)!
        : this outputs 42 :
\end{Verbatim}

\subsection{Control Logic}

All looping in DiGr is done in {\tt while} loops. A {\tt while} loop
begins with a logical boolean evaluation; if the evaluation results in
true, the body of the while block is executed. If it is false, the
block is skipped. Once the body is executed, the {\tt while} statement
is re-evaluated to check if it should run again. The syntax of the
loop is C-like: the condition to be tested follows the keyword {\tt
  while} in parenthesis, which is then followed by a statement block.

There are no "break" or "exit" commands to escape a while loop without
violating the while condition. To exit a while loop, the condition
must evaluate to false by the end of the while block. An example of a
while loop:

\begin{Verbatim}
        int fact = 1!
        int n = 5!
        while ( n > 1 ) {
	       fact = fact * n!
	       n = n - 1!
        }
        print(fact)! : prints 120
\end{Verbatim}

%\end{document}
